/**
 * Created by LiXiaoYan on 2017/06/22.
 */

'use.strict';
define(["app", "config", "service/service", "directive/headDir/headDir", 'angular-toastr', 'angular-toastr-tpls'], function(app, config) {
    app.register.controller('noticeNumber', ['$scope', '$state', 'commonService', 'baserHttp', '$http', 'OEMIDTRUE', '$rootScope', '$location', '$stateParams', 'toastr', function($scope, $state, commonService, baserHttp, $http, OEMIDTRUE, $rootScope, $location, $stateParams, toastr) {

        $scope.param = {};
        $scope.noticeSingle = {};
        if ($stateParams.noticeCode) {
            var txtNotice = $stateParams.noticeCode
            $scope.param['notice'] = txtNotice;


            baserHttp.$httpPost('/search/getCarTypeAndPartsTypeByNotice.do', JSON.stringify($scope.param), function(data) {
                if (data.result) {
                    $scope.noticeListNum = data.data;
                    if ($scope.noticeListNum.length > 0) {
                        $scope.activeIndex = 0;
                        $scope.noticeSingle = $scope.noticeListNum[0];
                    } else {
                        alert('没有查到');
                    }
                }
            });
        };

        //获取公告号监听的相关数据
        $scope.$on('noticeListNum', function(e, data) {
            $scope.noticeListNum = data;
        });
        //点击列表加载相关数据填充table表格
        $scope.activeBtn = function(item, index, e) {
            $scope.activeIndex = index;
            $scope.noticeSingle = item;
        };
        //点击确定按钮给头部传递五级分类的ID和partsId
        $scope.noticeSubmit = function() {
            $rootScope.noticeSingle = $scope.noticeSingle;
        }
    }])
})
